package com.dalin.framework.common.clazz;

import java.util.List;

import com.dalin.framework.common.clazz.ImportList;
import com.dalin.framework.common.clazz.Method;
import com.dalin.framework.common.clazz.PropertyList;
import com.dalin.framework.common.utils.StringUtils;
import com.dalin.framework.common.PropertyConst;

/*****************************************************************************
 * @content: 类的定义                                                                                                                               *
 * @author : 那建林                                                                                                                                 *
 * @crtDate: 2009-10-03                                                     *
 * @modDate: 2010-05-11                                                     *
 * @version: 1.11                                                           *
 ****************************************************************************/
public class Clazz {
	private String packageName; // 类包
	private ImportList importList; // 引入包
	private String note = ""; // 注释
	private String className; // 类名
	private String extendsClassName; // 继承类
	private List<String> implementsList; // 实现类;
	private PropertyList propertyList; // 类属性
	private List<Method> methodList; // 类方法

	public String toString() {
		StringBuffer sb = new StringBuffer();
		// 包名
		if (!StringUtils.isBlank(packageName)) {
			sb.append(PropertyConst.PACKAGE_STR).append(PropertyConst.SPACE).append(
					packageName).append(PropertyConst.SEMICOLON).append(
					PropertyConst.LINE_SEPARATOR).append(PropertyConst.LINE_SEPARATOR);
		}
		// 引用
		sb.append(importList == null ? "" : importList);
		// 类注释
		sb.append(Note.getClassNote());
		sb.append(note);
		// public class className
		sb.append(PropertyConst.PUBLIC_STR).append(PropertyConst.SPACE).append(
				PropertyConst.CLASS_STR).append(PropertyConst.SPACE)
				.append(className);
		// 是否有继承
		if (!StringUtils.isBlank(extendsClassName)) {
			sb.append(PropertyConst.SPACE).append(PropertyConst.EXTENDS_STR).append(
					PropertyConst.SPACE).append(extendsClassName);
		}
		// 是否实现接口
		if (!StringUtils.isBlank(implementsList)) {
			sb.append(PropertyConst.SPACE).append(PropertyConst.IMPLEMENTS_STR)
					.append(PropertyConst.SPACE);
			for (int i = 0; i < implementsList.size(); i++) {
				if (i > 0) {
					sb.append(PropertyConst.COMMA);
				}
				sb.append(implementsList.get(i)).append(PropertyConst.SPACE);
			}
		}
		sb.append(" " + PropertyConst.LEFT_BRACE).append(PropertyConst.LINE_SEPARATOR);
		// 私有属性;
		sb.append(propertyList == null ? "" : propertyList);
		sb.append(PropertyConst.LINE_SEPARATOR).append(PropertyConst.LINE_SEPARATOR).append(
				PropertyConst.LINE_SEPARATOR).append(PropertyConst.LINE_SEPARATOR).append(
				PropertyConst.LINE_SEPARATOR);
		// 公有方法;
		if (!StringUtils.isBlank(methodList)) {
			for (int i = 0; i < methodList.size(); i++) {
				sb.append(methodList.get(i).toClassMethodString());
			}
		}
		sb.append(PropertyConst.RIGHT_BRACE);
		return sb.toString();
	}
	
	
	
	
	public String getNote() {
		return note;
	}




	public void setNote(String note) {
		this.note = note;
	}




	public String getPackageName() {
		return packageName;
	}

	public void setPackageName(String packageName) {
		this.packageName = packageName;
	}


	public String getClassName() {
		return className;
	}

	public void setClassName(String className) {
		this.className = className;
	}

	public String getExtendsClassName() {
		return extendsClassName;
	}

	public void setExtendsClassName(String extendsClassName) {
		this.extendsClassName = extendsClassName;
	}

	public List<String> getImplementsList() {
		return implementsList;
	}

	public void setImplementsList(List<String> implementsList) {
		this.implementsList = implementsList;
	}
	public ImportList getImportList() {
		return importList;
	}
	public void setImportList(ImportList importList) {
		this.importList = importList;
	}
	public PropertyList getPropertyList() {
		return propertyList;
	}
	public void setPropertyList(PropertyList propertyList) {
		this.propertyList = propertyList;
	}
	public List<Method> getMethodList() {
		return methodList;
	}

	public void setMethodList(List<Method> methodList) {
		this.methodList = methodList;
	}
}